Skip to content

Initializers for joining a sequence of predicates#1878

Open
MatthewTurk247 wants to merge 4 commits intoswiftlang:mainfrom
MatthewTurk247:initializers-join-predicates
Open

Initializers for joining a sequence of predicates#1878
MatthewTurk247 wants to merge 4 commits intoswiftlang:mainfrom
MatthewTurk247:initializers-join-predicates

Conversation

@MatthewTurk247
Copy link
Copy Markdown
Contributor

This pull request implements the initializers proposed in #1860.

Testing:

See PredicateTests/all() and PredicateTests/any().

@MatthewTurk247 MatthewTurk247 requested a review from a team as a code owner April 4, 2026 02:53
Comment thread Tests/FoundationEssentialsTests/PredicateTests.swift
Comment thread Tests/FoundationEssentialsTests/PredicateTests.swift
@jmschonfeld
Copy link
Copy Markdown
Contributor

@swift-ci please test

@jmschonfeld
Copy link
Copy Markdown
Contributor

The build failures look to be caused by this change:

/__w/swift-foundation/swift-foundation/Sources/FoundationEssentials/Predicate/Predicate.swift:59:90: error: static method 'build_evaluate' requires the types 'PredicateExpressions.PredicateRegex' and 'Expression<repeat each Input, Bool>' be equivalent

@MatthewTurk247
Copy link
Copy Markdown
Contributor Author

Type inference is not working as I was expecting. I’ll add explicit annotations.


if let guarded = iterator.next() {
self.init({ (input: repeat PredicateExpressions.Variable<each Input>) in
let condition: PredicateExpressions.Value<Self> = PredicateExpressions.build_Arg(guarded)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change to pieces makes sense to me, but for condition should we just create it directly via

let condition = PredicateExpressions.Value(guarded)

No need to go through the builder functions here if they're getting in the way, especially build_Arg - it's really for the macro which doesn't know what the return type should be, but since we know it we can just create the Value directly if it helps the type checker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants